﻿
function GetDigo() {
    if ($("#goodnum").length === 0) {
        return;
    }
 
    $.ajax({
        type: "get",
        url: "/api/Digo/Get?contentId=" + ContentId,
        success: function (info) {
            $("#goodnum").text(info.GoodNum);
            $("#badnum").text(info.BadNum);
        }
    });

}

function Post_Digo(contentId, type) {
    $.ajax({
        type: "POST",
        url: "/api/Digo/Post?contentId=" + contentId + "&type=" + type,
        success: function (info) {
            if (info.errors === "") {
                GetDigo();
            }
            else {
                alert(info.errors);
            }
        }
    });

}
$(function() {
    $("#div_goodnum,#goodnum").click(function() { Post_Digo(ContentId, 'Good'); });

    $("#div_badnum,#badnum").click(function() { Post_Digo(ContentId, 'Bad'); });

    GetDigo();
});